/*
 * resultset_mysql.hpp
 *
 *  Created on: 2022年11月7日
 *      Author: dylan
 */

#ifndef _DM_OS_DB_RESULTSET_MYSQL_HPP_
#define _DM_OS_DB_RESULTSET_MYSQL_HPP_

#include <resultset.hpp>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>

namespace iotplat {

    class CResultSetMysql : public CResultSet {
        CResultSetMysql(const CResultSetMysql &);

        CResultSetMysql &operator=(const CResultSetMysql &);

    public:
        CResultSetMysql();

        ~CResultSetMysql();

        int size() const;

        bool next();

        void reset();

        bool asBool(int col) const;

        bool asBool(const char *col) const;

        int asInt(int col) const;

        int asInt(const char *col) const;

        uint asUint(int col) const;

        uint asUint(const char *col) const;

        double asDouble(int col) const;

        double asDouble(const char *col) const;

        std::string asString(int col) const;

        std::string asString(const char *col) const;

        bool isNull(int col) const;

        bool isNull(const char *col) const;

        int64_t asInt64(int col) const;

        int64_t asInt64(const char *col) const;

        int columnSize() const;

        std::string valueString(int col) const;

        std::string valueString(const char *col) const;

        void free();

        void set(sql::ResultSet *rst, sql::Statement *st);

    private:
        sql::ResultSet *m_rst;
        sql::Statement *m_st;
    };

}

#endif /* _DM_OS_DB_RESULTSET_MYSQL_HPP_ */
